package com.common.pager;

import javax.servlet.ServletRequest;

public class ParamUtil
{
	public static String getParameter(ServletRequest request, String paramName)
	{
		String temp = request.getParameter(paramName);
		if (temp != null && !temp.equals(""))
		{
			try
			{
				temp = java.net.URLDecoder.decode(temp, "UTF-8");
			} catch (Exception e)
			{
				return "";
			}
			return temp;
		} else
		{
			return "";
		}
	}

	public static int getIntParameter(ServletRequest request, String paramName,
			int defaultNum)
	{
		String temp = request.getParameter(paramName);
		if (temp != null && !temp.equals(""))
		{
			int num = defaultNum;
			try
			{
				num = Integer.parseInt(temp);
			} catch (Exception ignored)
			{
			}
			return num;
		} else
		{
			return defaultNum;
		}
	}
}
